package mlp.game.applebucking;

import com.overkill.game.ColorFilterGenerator;
import com.overkill.game.Sprite;
import com.overkill.game.SpriteRenderable;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;

public class Cart extends SpriteRenderable {

	Paint colorHue = new Paint();
	int hueShift = 0;
	boolean zapMode = false;
	
	
	public Cart(Sprite sprite) {
		super(sprite);
	}

	@Override
	public void update(long gameTime) {
		super.update(gameTime);
		if(zapMode){
			hueShift += 5;
			if(hueShift > 180){
				hueShift = -180;
			}
		} else {
			hueShift = 0;
		}
		colorHue.setColorFilter(ColorFilterGenerator.adjustHue(hueShift));
	}
	
	@Override
	public void draw(Canvas canvas) {
		super.draw(canvas, colorHue);
	}
	
	public void setHitBox(RectF hitBox) {
		setRelativHitBox(hitBox);
	}
		
	public boolean isCaught(Apple apple){
		boolean isCaught = isHit(apple);
		if(isCaught){
			getSprite().play();
		}
		return isCaught;
	}

	public boolean isZapMode() {
		return zapMode;
	}

	public void setZapMode(boolean zapMode) {
		this.zapMode = zapMode;
	}	
}
